<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no" />
    <title>title</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css"/>
    <style>
        html, body {
            background-color: #f8f8f8;
        }
        .main {
        	background-color: #fff;
        }
        .main ul li .li_box {
        	height: 65px;
        	border-bottom: 1px solid #e8e8e8;
        	display: -webkit-box;
        	display: -webkit-flex;
        	align-items: center;
        	padding: 0 15px;
        }
        .main ul li:last-child .li_box {
        	border-bottom: none;
        }
        .main ul li .li_box .li_boxl .li_img {
			width: 45px;
			height: 45px;			
        }
        .main ul li .li_box .li_boxl .li_img img {
        	width: 100%;
        	height: 100%;
        	object-fit: cover;
        }
        .main ul li .li_box .li_boxc {
        	width: 0;
        	flex: 1;
        	-webkit-flex: 1;
        	box-flex: 1;
        	-webkit-box-flex: 1;
        	padding: 0 10px;
        }
        .main ul li .li_box .li_boxc .title {
			font-size: 15px;
			color: #333;
			overflow: hidden;
			text-overflow: ellipsis;
			white-space: nowrap;
            margin-bottom: 10px;
        }
        .main ul li .li_box .li_boxc .time {
        	color: #999;
        	font-size: 12px;
        }
        .main ul li .li_box .li_boxr img {
        	height: 13px;
        	display: block;
        }
        .without_data{
            display: none;
            color:#ccc;
            text-align:center;
            line-height: 30px;
            padding:10px;
            background: #f8f8f8;
        }
    </style>
</head>
<body>
    <div class="main">
    	<ul id="comment_ul">
<!--     		<li tapmode onclick="fnEvaluateOrder();">
    			<div class="li_box">
    				<div class="li_boxl">
    					<div class="li_img">
    						<img src="../image/temp/1.png">
    					</div>
    				</div>
    				<div class="li_boxc">
    					<div class="title">商家名称</div>
    					<div class="time">2017-09-08 12:42:14</div>
    				</div>
    				<div class="li_boxr">
    					<img src="../image/right.png">
    				</div>
    			</div>
    		</li> -->
    	</ul>
        <div class="without_data">暂无评价</div>
    </div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/zepto.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript" src="../script/doT.min.js"></script>
<script id="commentTpl" type="text/x-dot-template">
    {{ for(var i=0;i<it.length;i++){ }}
        <li tapmode onclick="fnEvaluateOrder({{=it[i]['id']}},{{=it[i]['order_id']}});">
            <div class="li_box">
                <div class="li_boxl">
                    <div class="li_img">
                        <img src="../image/default.png">
                        <img onload="setImg(this);" style="display: none;" src="{{=formatHeadImg(it[i]['img'])}}">
                    </div>
                </div>
                <div class="li_boxc">
                    <div class="title">{{=it[i]['name']}}</div>
                    <div class="time">{{=it[i]['create_time']}}</div>
                </div>
                <div class="li_boxr">
                    <img src="../image/right.png">
                </div>
            </div>
        </li>
    {{ }; }}
</script>
<script type="text/javascript">
    apiready = function(){
        p = 1;
        openLoading();
        fnGetComment();

        api.setCustomRefreshHeaderInfo({
            bgColor: '#f8f8f8',
            loadAnimInterval:60,
            image: {
               pull: pullArr,
               load: loadArr
            }
        }, function() {
            p=1;
            fnGetComment(1);
        });

                //距离底部加载
        api.addEventListener({
            name:'scrolltobottom',
            extra:{
                threshold: 0           //设置距离底部多少距离时触发，默认值为0，数字类型
            }
        }, function(ret, err){        
            p++;
            fnGetComment(2);
            
        });
    };

    // 评价订单
    function fnEvaluateOrder(id,order_id) {
        api.openWin({
            name: 'evaluate_order',
            url: 'evaluate_order.html',
            pageParam: {
                id:id,
                order_id:order_id
            }
        });
    }

    function fnGetComment(type) {
        user = $api.getStorage('user_data');
        api.ajax({
            url: rootPath+'/api/user/comment_list',
            method: 'get',
            data: {
                values: { 
                    uid: user.id,
                    token:user.token,
                    p : p
                },
            }
        }, function(ret, err) {
            //type=1 下拉刷新，清除原来数据
            if(type == 1) {
                $('#comment_ul').empty();
            }
            if (ret) {
                if(ret.status == 200) {
                    $('.without_data').hide();
                    appendDotData(ret.data,'commentTpl','comment_ul',true,false);
                }else {
                    if(p == 1) {
                        $('.without_data').show();
                    }
                }
            } else {
                showError(err.code,err.msg)
            }
            if(type == 1) {
                // 是下拉刷新的，要收回
                api.refreshHeaderLoadDone();
            }
            if(type == 2) {
                //上拉给点假时间,好看些         
                setTimeout(function(){
                    $(".loading").hide();
                },1000);
            }else {
                $('.loading').hide();

            }
            closeLoading();
        });
    }
</script>
</html>